<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/9/3
 * Time: 16:54
 */
$TaskName =$_POST['TaskName'] ?? '';

$TaskContent =$_POST['TaskContent'] ?? '';

// 把班级信息存储到数据库
$dsn = "sqlsrv:Server=LAPTOP-GQ4AGRUA\SQLEXPRESS;Database=Task";
$db = new PDO($dsn, "sa", "123456");

$sql = "insert into Task (TaskName,TaskContent) values('{$TaskName}','($TaskContent)') ";
$result = $db->exec($sql);
if ($result) {
    echo '增加任务成功，前往<a href="list.php">列表页</a>';
} else {
    echo '添加失败';
}